package com.kefu.call.vo;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.vo.AbstractSearchVo;
import com.kefu.call.model.CurlProfile;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author CodeGenerator
 * @date 2022/07/24
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "驱动")
public class CurlProfileSearchVo extends AbstractSearchVo {

    @ApiModelProperty(value = "名称")
    private String name;
    @ApiModelProperty(value = "值 [internal,external]")
    private String val;
    @ApiModelProperty(value = "IP地址【$${local_ip_v4}代表本地地址】，必须内网地址")
    private String ip;
    @ApiModelProperty(value = "端口")
    private Integer port;
    @ApiModelProperty(value = "是否开启")
    private Integer istrue;
    @ApiModelProperty(value = "媒体地址，必须内网地址")
    private String rtpip;
    @ApiModelProperty(value = "日志地址")
    private String captureserver;
    @ApiModelProperty(value = "如果fs再外网，需要改成外网地址。来做nat处理。contact")
    private String extSip;
    @ApiModelProperty(value = "如果fs再外网，需要改成外网地址。来做nat处理。sdp地址")
    private String extRtp;

	 @Override
    public  LambdaQueryWrapper<CurlProfile> lambdaQuery(){
    	LambdaQueryWrapper<CurlProfile> wrapper=Wrappers.<CurlProfile>lambdaQuery();
	    wrapper.eq(StringUtils.isNotBlank(name), CurlProfile::getName, name);//名称
	    wrapper.eq(StringUtils.isNotBlank(val), CurlProfile::getVal, val);//值 [internal,external]
	    wrapper.eq(StringUtils.isNotBlank(ip), CurlProfile::getIp, ip);//IP地址【$${local_ip_v4}代表本地地址】，必须内网地址
		wrapper.eq(port!=null, CurlProfile::getPort, port);//端口
		wrapper.eq(istrue!=null, CurlProfile::getIstrue, istrue);//是否开启
	    wrapper.eq(StringUtils.isNotBlank(rtpip), CurlProfile::getRtpip, rtpip);//媒体地址，必须内网地址
	    wrapper.eq(StringUtils.isNotBlank(captureserver), CurlProfile::getCaptureserver, captureserver);//日志地址
	    wrapper.eq(StringUtils.isNotBlank(extSip), CurlProfile::getExtSip, extSip);//如果fs再外网，需要改成外网地址。来做nat处理。contact
	    wrapper.eq(StringUtils.isNotBlank(extRtp), CurlProfile::getExtRtp, extRtp);//如果fs再外网，需要改成外网地址。来做nat处理。sdp地址
	    
    	return wrapper;
	}
}